<div id='Main_AdminUser_Area1'>
	<h2 style='text-align:center'>后台成员管理</h2>

	<button id='MainAdminUser_Add'>添加管理成员</button>
	<div id='MainAdminUser_AddUserArea' style='display:none'>
		<div><input id='MainAdminUser_AddName' placeholder='用户名' /></div>
		<div><input id='MainAdminUser_AddPwd' type='password' placeholder='密码' /></div>
		<div><input id='MainAdminUser_AddInfo' placeholder='备注' /></div>
		<div>
			<button id='MainAdminUser_AddBtn'>添加</button>
			<button id='MainAdminUser_AddCancel'>取消</button>
		</div>
	</div>


	<div style='margin:20px auto' id='MainAdminUser_ListArea'>
		<div style='border-bottom:1px solid #999;margin:5px auto;display:flex'>
			<span style='margin:5px 10px '>a1</span>
			<span style='margin:5px 10px '>2018-12-12</span>
			<span style='flex:1;margin:5px 10px;word-break:break-all'>sdfsdfsfsdfsdfsfsdfsdfsfsdfsdfsfsdfsdfssdfsdfsfsdfsdfsfsdfsdfsfsdfsdfsfsdfsdfsf</span>
			<span style='margin:5px 10px '><button>删除</button></span>
		</div>
	</div>
</div>


<!--存放权限管理页-->
<div id='Main_AdminUser_Area2'></div>



<script>


	_getAdminUserList();	//获取管理员列表

	//显示添加区域
	$('#MainAdminUser_Add').click(function(){
		$('#MainAdminUser_AddUserArea').show();
	});

	//隐藏添加区域
	$('#MainAdminUser_AddCancel').click(function(){
		$('#MainAdminUser_AddUserArea').hide();
	});

	//添加用户的提交
	$('#MainAdminUser_AddBtn').click(function(){
		var name = ChangeChar($('#MainAdminUser_AddName').val().trim());
		var pwd = ChangeChar($('#MainAdminUser_AddPwd').val().trim());
		var info = ChangeChar($('#MainAdminUser_AddInfo').val().trim());

		Field_Check(/^[a-z]\w{1,10}$/,name,'js非法用户名!');
		Field_Check(/^.{1,}$/,pwd,'js密码非法!');

		var data = {
			type:'adminUserAdd',
			name:name,
			pwd:pwd,
			info:info
		};
		AjaxAdmin(data,function(res){
			var tmp = _checkJsonFormat(res);
			if(tmp.stat == 'ok'){
				A('操作成功！');
				location.reload();
			}else if(tmp.stat == 'err3'){
				A('用户已存在！');
			}else{
				A('操作失败！');
			}
		});
	});



	//获取管理员列表
	function _getAdminUserList(sess_stat){
		var data = {
			type:'getAdminUserList'
		};
		AjaxAdmin(data,function(res){
			var tmp = _checkJsonFormat(res);
			_getAdminUserListParse(tmp.data);
		});
	}




	//解析管理员列表
	function _getAdminUserListParse(list){
		var str = '';
		for(var i=0;i<list.length;i++){
			str += "<div style='border-bottom:1px solid #999;margin:5px auto;display:flex'>";
			str += "	<span style='margin:5px 10px '>"+list[i].name+"</span>";
			str += "	<span style='margin:5px 10px;color:#55a '>"+list[i].ctime+"</span>";
			str += "	<span style='flex:1;margin:5px 10px;word-break:break-all;color:#777'>"+list[i].remarks+"</span>";
			str += "	<span style='cursor:pointer;font-size:13px;margin:5px 10px'><span onclick=MainAdminUser_UserDel("+list[i].id+")>删除</span> <span onclick=MainAdminUser_Control("+list[i].id+",'"+list[i].name+"')>管理</span></span>";
			str += "</div>";
		}
		$('#MainAdminUser_ListArea').html(str);
	}



	//删除管理用户
	function MainAdminUser_UserDel(id){
		if(!_confirm()){
			return;
		}
		var data = {
			type:'adminUserDel',
			id:id
		};
		AjaxAdmin(data,function(res){
			var tmp = _checkJsonFormat(res);
			if(tmp.stat == 'ok'){
				A('操作成功！');
				location.reload();
			}else{
				A('操作失败！');
			}
		});
	}


	//重置用户密码
	function MainAdminUser_Control(id,user){
		if(!id){
			A('缺少用户id!');return;
		}
		sessionStorage.admin_MainAdminUser_ControlId = id;
		sessionStorage.admin_MainAdminUser_ControlUser = user;
		$('#Main_AdminUser_Area1').hide();
		Ajax({},function(res){
			$('#Main_AdminUser_Area2').html(res).show();
		},'Template/Main_AdminUserPerm.html');
	}







</script>